package com.escape.wx.handler;

import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * @Author: escape_zebra
 * @CreateTime: 2025-01-16  20:35
 * @Description: 订阅工厂实现类
 * @Version: 1.0
 */
@Component
@Slf4j
public class SubscribeMsgHandler implements WxChatMsgHandler {

    @Override
    public WxChatMsgTypeEnum getMsgType() {
        return WxChatMsgTypeEnum.SUBSCRIBE;
    }

    @Override
    public String dealMsg(Map<String, String> messageMap) {
        log.info("订阅工厂类触发!");
        String toUserName = messageMap.get("ToUserName");
        String fromUserName = messageMap.get("FromUserName");
        String content = "欢迎订阅 Escape_Zebra 的测试公众号，如果需要登录经典鸡翅平台，请输入'验证码'三个字，如果觉得自己太富有，请 v 我50，诚信感谢！";

        return "<xml><ToUserName><![CDATA["+fromUserName+"]]></ToUserName>\n" +
                "<FromUserName><![CDATA["+toUserName+"]]></FromUserName>\n" +
                "<CreateTime>1737029098</CreateTime>\n" +
                "<MsgType><![CDATA[text]]></MsgType>\n" +
                "<Content><![CDATA["+content+"]]></Content>\n" +
                "<MsgId>24868275616129270</MsgId>\n" +
                "</xml>";
    }
}